Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve resilience of api pkg tests #4676

Merged
merged 5 commits into from
Sep 18, 2018
Merged

Conversation

freddygv
Copy link
Contributor

@freddygv freddygv commented Sep 14, 2018

In other parts of the codebase we have been using waits to avoid running into missing serfHealth registration. In those cases we have been using testrpc.WaitForTestAgent, but that function cannot be used in the api package because it leads to a dependency cycle.

This PR adds a wait for serfHealth to the TestServer that is created for api tests.

This wait is added to session tests because in session.Create we require that all checks be registered.

Lastly the test client for semaphore tests is now spun up with Connect disabled, as is done in the lock tests.

After making these changes all semaphore and session tests are passing consistently in the repro environment.


Update

Added some more changes.

From this CI job we can see that running the semaphore/lock tests with Connect disabled isn't enough to make them as robust as we would like.

Under the hood, locks and semaphores create sessions with session.Create. To avoid the associated check for serfHealth, this PR creates sessions with session.CreateNoChecks and then feeds that in when locks/semaphores are created.

In cases where custom semaphore/lock options were already being passed in, there is now a WaitForSerfCheck instead.

Additionally, travis will now log tests as they pass to avoid situations like this one.

@freddygv
Copy link
Contributor Author

@pierresouchay this PR is good for you to be aware of

Copy link
Contributor

@pierresouchay pierresouchay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great fix

@freddygv freddygv requested a review from banks September 14, 2018 14:44
@freddygv
Copy link
Contributor Author

freddygv commented Sep 14, 2018

@banks A lingering concern I have about creating lock/semaphore sessions without checks is that the serfHealth check is the only liveness check that sessions use (unless another is specified).

I think It's not causing any tests to fail because we don't have any tests killing a node and then checking if the slot was released. (or maybe that's what TestAPI_SemaphoreMonitorRetry is doing, which I'm not skipping the reg check for)

Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Thanks @freddygv!

@banks banks merged commit 524192c into hashicorp:master Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants